(function () {

    let pathName = window.location.pathname,
        top_nav = $('#top-nav > li > a'),
        links = $('.links > li > a');

    for (let i = 0; i < top_nav.length; i++) {
        if (top_nav[i].href.indexOf(pathName) > -1) {
            $(top_nav[i]).addClass('active');
        }
    }

    for (let i = 0; i < links.length; i++) {
        if (links[i].href.indexOf(pathName) > -1) {
            $(links[i]).parent().addClass('active');
        }
    }

    $('.links > li').on('touchstart', function () {
        $(this).siblings().removeClass('active');
    })

    $(".icon-nav").on('touchstart', function () {
        $(".phone-links").animate({left: 0}, "slow", function () {
            $(document).on("touchmove", function (e) {
                e.preventDefault();
                e.stopPropagation();
            }, false);
        });
    });

    $(".icon-close").on('touchstart', function () {
        $(".phone-links").animate({left: '-100vw'}, "slow", function () {
            $(document).off("touchmove");
        });
    });
    
})();
